<?php

/*

Club include (club.inc.php)

*/

mysql_query("UPDATE clubs2 SET hits = hits + 1 WHERE id = '$clubid' AND game = '$game'");

$getclub = fetch("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'");
if (!$getclub[id])
{
	die(header(error("club.php?game=$game","This is not a real club.")));
}

$getmemberdata = fetch("SELECT * FROM club_members2 WHERE club = '$clubid' AND user = '$userid' AND game = '$game'");
$getmemberdata4 = fetch("SELECT * FROM club_members2 WHERE user = '$userid' AND game = '$game'");
if (!$getmemberdata[id])
{
	$getmemberdata[position] = 0;
}
$clubrank = $getmemberdata[position];
if ($clubrank == 0)
{
	$position = "Visitor, <a href=$base_url/club_join.pro.php?game=$game&clubid=$clubid><font color=$topAndBottomText>join</font></a>";
}
if ($clubrank == 1)
{
	$position = "Member, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 2)
{
	$position = "Moderator, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 3)
{
	$position = "Admin";
	$club_admin_line = "<br><a href=club_admin.php?game=$game&clubid=$clubid>Admin Page</a>";
}

if ($clubrank < $clubrank_check)
{
	die(header(error("club.php?game=$game","You do not have access to this page.")));
}

$num_members = mysql_num_rows(mysql_query("SELECT id FROM club_members2 WHERE club = '$clubid' AND game = '$game'"));
$date_created = date("M j, Y",$getclub[datecreated]);
$owner = fetch("SELECT display_name FROM members2 WHERE id = '$getclub[owner]' AND game = '$game'");

$numPosts = mysql_num_rows(mysql_query("SELECT id FROM club_forums2 WHERE club = '$clubid'"));

$topmenu = "
<center><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\" width=100%><td><p><font color=$topAndBottomText><b>$getclub[name]</b> <i>owned by $owner[display_name]</i></font></p></td><td width=150><p><font color=$topAndBottomText>$display_name ($position)</font></p></td></tr><tr height=100 bgcolor=\"$reallyLight\"><TD colspan=2><p align=center><b><i>$getclub[motto]</i></b></p><center><table bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1 width=375><tr bgcolor=\"$topAndBottomBG\"><td width=50%><p align=center><b><font color=$topAndBottomText>Stats</font></b></p></td><td width=50%><p align=center><b><font color=$topAndBottomText>Links</font></b></p></td></tr><tr bgcolor=\"$reallyLight\"><td valign=top>

<p>Members: <a href=club_members.php?game=$game&clubid=$clubid>$num_members</a><br>
Created: $date_created<Br>
Hits: $getclub[hits]</p>

</td><td valign=top>

<p><a href=$base_url/club.php?game=$game&clubid=$clubid>Home</a><br>
<a href=$base_url/club_forums.php?game=$game&clubid=$clubid>Chat Boards</a> ($numPosts Posts)
$club_admin_line</p></td>

</tr></table><Br></center></td></tr></table>";

$startClub = "<Br>$topmenu<br><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\"><td><p align=left class=white><b>$page_heading</b></p></td></tr><tr bgcolor=\"$maincellColor\"><td>";
$endClub = "</td></tr></table></center><br>";

?>